﻿/// <reference path="../../knockout-2.1.0.js" />
/// <reference path="../../knockout.mapping-latest.js" />
/// <reference path="../shared/utils.js" />
/// <reference path="../../jquery-1.7.2-vsdoc.js" />
/// <reference path="../../knockout.wrap.js" />


function ExamenPsicosensometrico(data) {
    var self = this;

    self.Load = function (info) {
        ko.mapping.fromJS(info, {}, this);
    };

    if (data) {
        self.Load(data);
        individuoDetalleControl.Load(data.IndividuoId);
    }
}


function ExamenPsicosensometricoViewModel(model) {
    var self = this;
    self.ExamenPsicosensometrico = ko.observable();
    self.Mensaje = ko.observable();
    self.HaveErrors = ko.observable();
    self.Load = function (response) {
        self.ExamenPsicosensometrico(new ExamenPsicosensometrico(response));
    };

    self.Guardar = function () {
        ajax('../GuardarExamenPsicosensometrico', ko.mapping.toJSON(self.ExamenPsicosensometrico()), function (result) {
            if (result.isValid) {
                self.Mensaje("Examen Guardado!!! </b>");
                $('#modalsaved').modal();
                /*algo*/
            } else {
                /*algo*/
                self.Mensaje(result.message);
                $('#modalError').modal();
            }
        });
    };
    if (model)
        self.Load(model);

};

function startApp(model) {
    ko.applyBindings(new ExamenPsicosensometricoViewModel(model), document.getElementById("examenPsicosensometricoContext"));
}

